// The Vue build version to load with the `import` command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
import Vue from 'vue'
import router from './router'
import ElementUI from 'element-ui';
import 'element-ui/lib/theme-chalk/index.css';
import App from './App'
// 图表
import echarts from 'echarts'
Vue.prototype.$echarts = echarts;

//定义全局 时间过滤器 S
import Moment from 'moment';
// 定义全局时间戳过滤器
Vue.filter('formatDate', function(value) {
  return Moment(value).format('YYYY-MM-DD HH:mm:ss')
})

// 文件上传地址
Vue.prototype.$fileUpload = 'http://kghnpgccj.hw.hanguosoft.com/api/file/upload'
Vue.config.productionTip = false
Vue.use(ElementUI);


// 公共方法
Vue.mixin({
  data() {
    return {
      subjects: []
    }
  },
  methods: {
    beforeAvatarUpload(file) {
      const isJPG = file.type === 'image/jpeg' || file.type === 'image/png';
      const isLt2M = file.size / 1024 / 1024 < 2;

      if (!isJPG) {
        this.$message.error('上传头像图片只能是 JPG 格式!');
      }
      if (!isLt2M) {
        this.$message.error('上传头像图片大小不能超过 2MB!');
      }
      return isJPG && isLt2M;
    },
    //预览图片
    handleAvatarSuccess(res, file) {
      this.imageUrl = URL.createObjectURL(file.raw);
    },
    // 放大图片
    enlargement(url){
      let src="<img src='"+url+"' style='width:100%'/>"
      this.$alert(src, "预览", {
        dangerouslyUseHTMLString: true
      });
    },
  }
});
/* eslint-disable no-new */
new Vue({
  el: '#app',
  router,
  components: { App },
  template: '<App/>'
})
